package cn.com.common;

import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * 规则模型对象
 *
 * @author jiaming
 */
@Data
public class RuleModel implements Serializable {

    private static final long serialVersionUID = -1L;

    /**
     * 应用名称
     */
    private String appName;

    /**
     * 规则名称
     */
    private String ruleName;

    /**
     * 规则key
     */
    private String ruleKey;

    /**
     * 是否前缀匹配
     */
    private boolean prefix;

    /**
     * hotkey的阈值
     */
    private long threshold;

    /**
     * 本地缓存时间，单位秒
     */
    private int duration;

    /**
     * hotkey 探测间隔，单位秒
     */
    private int interval;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RuleModel ruleModel = (RuleModel) o;
        return appName.equals(ruleModel.appName) && ruleKey.equals(ruleModel.ruleKey);
    }

    @Override
    public int hashCode() {
        return Objects.hash(appName, ruleKey);
    }
}